﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ModelLibrary;

namespace WebC
{
    public partial class device_depttree : clsBaseForm
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            loadInfo();
        }

        void loadInfo()
        {
            BuyDevice buy = null;
            DataTable dt = null;
            string sRightPage = Convert.ToString(Request["turl"]);
            try
            {
                buy = new BuyDevice();
                string sFullName = "";
                switch (sRightPage)
                {
                    case "applist":
                        if (!checkModelRightById(203, ref sFullName, (clsBaseLib)buy))
                        {
                            errorUrl(string.Format("你没有“{0}”的权限,请与管理员联系！", sFullName));
                            return;
                        }
                        break;
                    case "Devicelist":
                        if (!checkModelRightById(251, ref sFullName, (clsBaseLib)buy))
                        {
                            errorUrl(string.Format("你没有“{0}”的权限,请与管理员联系！", sFullName));
                            return;
                        }
                        break;
                    case "DevPartList":
                        if (!checkModelRightById(191, ref sFullName, (clsBaseLib)buy))
                        {
                            errorUrl(string.Format("你没有“{0}”的权限,请与管理员联系！", sFullName));
                            return;
                        }
                        break;
                    case "RepairApplist":
                        if (!checkModelRightById(151, ref sFullName, (clsBaseLib)buy))
                        {
                            errorUrl(string.Format("你没有“{0}”的权限,请与管理员联系！", sFullName));
                            return;
                        }
                        break;
                    case "DevMaintainlist":
                        if (!checkModelRightById(161, ref sFullName, (clsBaseLib)buy))
                        {
                            errorUrl(string.Format("你没有“{0}”的权限,请与管理员联系！", sFullName));
                            return;
                        }
                        break;
                }
                dt = buy.getDeptTree();

            }
            catch (Exception e)
            {
                errorUrl(Convert.ToString(e));
            }
            finally
            {
                if (buy != null)
                {
                    buy.Dispose();
                }
            }
            string sURL = string.Format("{0}.aspx?deptid={1}", Request["turl"], "{0}");
            tree.ininTree(dt, this.tvDept, sURL, true);
        }
    }
}